cmake_minimum_required(VERSION 3.10)
project(hdfs)

set(CMAKE_CXX_STANDARD 11)
include_directories(${PROJECT_SOURCE_DIR}/include)
# 指定Java JRE libjvm.so的路径，javaHome的目录西的libjvm.so
set(JAVA_JRE_LIB_DIR "/export/server/jdk1.8.0_241/jre/lib/amd64/server")

# 查找HDFS库
find_library(HDFS_LIBRARY NAMES hdfs PATHS /export/server/hadoop-3.3.0/lib/native REQUIRED)

# 查找或假设找到libjvm.so
find_library(JVM_LIBRARY NAMES jvm HINTS ${JAVA_JRE_LIB_DIR} REQUIRED)

# 创建应用目标并链接所需的库，包括隐式依赖于libjvm.so的hdfs库
add_executable(app main.cpp operate_hdfs.cpp)
target_link_libraries(app PRIVATE ${HDFS_LIBRARY} ${JVM_LIBRARY})
# 运行命令 https://cloud.tencent.com/developer/ask/sof/114787036
# CLASSPATH=$CLASSPATH:`hadoop classpath` ./app